home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
clipper
/
nfsrc21.zip
/
POPADDER.PRG
< prev
next >
Wrap
Text File
|
1991-08-17
|
45KB
|
1,292 lines
/*
* File......: Popadder.prg
* Author....: Keith A. Wire
* CIS ID....: 73760,2427
* Date......: $Date: 17 Aug 1991 15:44:30 $
* Revision..: $Revision: 1.2 $
* Log file..: $Logfile: E:/nanfor/src/popadder.prv $
*
* This is an original work by Keith A. Wire and is placed in the
* public domain.
*
* Modification history:
* ---------------------
*
* $Log: E:/nanfor/src/popadder.prv $
*
* Rev 1.2 17 Aug 1991 15:44:30 GLENN
* Don Caton fixed some spelling errors in the doc
*
* Rev 1.1 15 Aug 1991 23:04:12 GLENN
* Forest Belt proofread/edited/cleaned up doc
*
* Rev 1.0 14 Jun 1991 17:37:54 GLENN
* Initial revision.
*
*/
/*
* File......: Popadder.prg
* Author....: Keith A. Wire
* CIS ID....: 73760,2427
* Date......: $Date: 17 Aug 1991 15:44:30 $
* Revision..: $Revision: 1.2 $
* Log file..: $Logfile: E:/nanfor/src/popadder.prv $
*
* This is an original work by Keith A. Wire and is placed in the
* public domain.
*
* Modification history:
* ---------------------
*
* $Log$
*
* Rev 1.0 14 Jun 1991 17:37:54 GLENN
* Initial revision.
*
*/
/* $DOC$
* $FUNCNAME$
* FT_Adder()
* $CATEGORY$
* Menus/Prompts
* $ONELINER$
* Pop up a simple calculator
* $SYNTAX$
* FT_Adder()
* $ARGUMENTS$
* None
* $RETURNS$
* NIL .... but optionally places Total of calculation in active
* Get variable using oGet:VARPUT()
* $DESCRIPTION$
* PopAdder() gives you an adding machine inside your Clipper 5.01
* application. It has the basic functions add, subtract, multiply,
* and divide. You may move it from one side of the screen to the
* other. It even displays a scrollable tape, if you want it.
*
*
* The Help screen below gives a brief description of the operation
* of the adder.
*
*
* ┌─────── INSTRUCTIONS ───────┐
* │ │
* │ All number keys as usual │
* │ <+> <-> keys as usual │
* │ <SPACE>─┬─shift <+> to <*> │
* │ └─shift <-> to </> │
* │ <D> change decimal pt. │
* │ <M> move ADDER │
* │ <T> display tape │
* │ <S> scroll tape disp. │
* │ <DEL>───┬─1st Clear entry │
* │ └─2nd Clear ADDER │
* │ <ESC> to Quit │
* │ <F10> to Return Total │
* │ to program │
* │ │
* └──── Any Key to Continue ───┘
*
*
*
* A couple of notes about the adder:
*
*
* 1.) It was designed to be used on an Enhanced keyboard with
* separate <DELETE> key. <DELETE> is used to clear the adder.
* However, it will still work on a Standard keyboard.
*
* 2.) It uses the <SPACE> bar to shift from Add/Subtract
* mode to Multiply/Divide. That means the <+> and <-> keys
* become the <*> and </> keys.
*
* 3.) You do not have to display the tape. You may turn it on
* at any time by pressing <T>. You may SCROLL back through
* the tape once there are more than 16 entries in the
* adder, by pressing <S>.
*
* 4.) To Quit the Adder just press <ESC>. To return your Total
* to the application press <F10>. The adder will place the
* Total in the active GET variable using oGet:VarPut(). The
* adder will only return a Total to a numerical GET!
*
* 5.) There are many support functions that you might find
* interesting. They are part of my personal library, but
* are necessary to the operation of the adder.
* You might want to pull these out to reduce the overall
* size of the adder. Many are worth at least a little
* time studying.
*
* 6.) To make FT_Adder a Hot key from inside your application
* at the beginning of your application add the line:
*
* SET KEY K_ALT_A TO FT_Adder
*
* This will make <ALT-A> a key "Hot" and permit you to
* Pop - Up the adder from anywhere in the application.
*
* 7.) If you use FT_SINKEY(), you can even have active hotkeys
* in an INKEY().
*
*
*
*
* $EXAMPLES$
*
* $SEEALSO$
*
* $INCLUDE$
* INKEY.CH, SET.CH, SETCURS.CH, ACHOICE.CH
* $END$
*/
#include 'Inkey.ch'
#include 'Set.ch'
#include 'SetCurs.ch'
#include 'achoice.ch'
#define K_PLUS 43
#define K_MINUS 45
#define K_SPACE 32
#define nTotTran LEN(aTrans)
#define MUST_READ .T.
#define POP_ON .T.
#define POP_OFF .F.
#define B_DOUBLE '╔═╗║╝═╚║ '
#define B_SINGLE '┌─┐│┘─└│ '
// Set up manifest constants to access the window colors in the array aWinColor
#define W_BORDER 1
#define W_ACCENT 2
#define W_PROMPT 3
#define W_SCREEN 4
#define W_TITLE 5
#define W_VARIAB 6
#define W_CURR NIL
// Set up manifest constants to access the Standard screen colors in the array
// aStdColor
#define STD_ACCENT 1
#define STD_ERROR 2
#define STD_PROMPT 3
#define STD_SCREEN 4
#define STD_TITLE 5
#define STD_VARIABLE 6
#define STD_BORDER 7
/* This ASHRINK is by Rick Spence */
#define ASHRINK(ar) ASIZE(ar,LEN(ar)-1)
#command DISPMESSAGE <mess>,<t>,<l>,<b>,<r> => ;
_ftPushKeys(); KEYBOARD CHR(K_CTRL_PGDN)+CHR(K_CTRL_W);;
MEMOEDIT(<mess>,<t>,<l>,<b>,<r>); _ftPopKeys()
/* This INKEY UDC was posted by Don Caton on NanForum... Thanks Don <g> */
#command INKEY [ <secs> ] TO <var> ;
=> ;
WHILE (.T.) ;;
<var> := Inkey([ <secs> ]) ;;
IF Setkey(<var>) # NIL ;;
Eval( Setkey(<var>), ProcName(), ProcLine(), #<var> ) ;;
ELSE ;;
EXIT ;;
END ;;
END
MEMVAR getlist
STATIC nTotal,nNumTotal,nSavTotal,cDefTotPict,cTotPict,lShowRight
STATIC nAddSpace,nTapeSpace,nTopTape,lClAdder,lDecSet,nDecDigit,nMaxDeci
STATIC lMultDiv,nAddMode,lSubRtn,cTapeScr,lTotalOk,lAddError
STATIC aTrans,lTape, nTopOS, nLeftOS, lNewNum, nSavSubTotal, lDivideErr
STATIC aHelpStack := {}, aKeys := {}
STATIC lStatMustRing := .T. // Change this to .F. if you don't
// want the bell on inputs
STATIC aWindow := {}, nWinColor := 0
STATIC aWinColor, aStdColor
#ifdef FT_TEST
FUNCTION TEST
LOCAL nSickHrs := 0, ;
nPersHrs := 0, ;
nVacaHrs := 0
aWinColor := { {'GR+/BG','GR+/G', 'B+/RB', 'G+/R'} , ;
{'R+/N', 'W+/RB','W+/BG','GR+/B'} , ;
{'GR+/N', 'GR+/N','GR+/N', 'GR+/N'} , ;
{ 'B/BG','BG+/G', 'W+/RB','BG+/R'} , ;
{ 'W+/BG', 'W+/G','GR+/RB', 'W+/R'} , ;
{'GR+/B', 'GR+/R', 'R+/B', 'W+/BG'},;
{ 'N/N', 'N/N', 'N/N', 'N/N'} }
aStdColor := { 'BG+*/RB' , ;
'GR+/R' , ;
'GR+/N' , ;
'W/B' , ;
'GR+/N' , ;
'GR+/GR' , ;
{ 'W+/B', 'W/B','G+/B','R+/B',;
'GR+/B','BG+/B','B+/B','G+/B'},;
'N/N' }